package com.lxh.libmanager.web.controller;


import com.lxh.libmanager.common.Const;
import com.lxh.libmanager.entity.User;
import com.lxh.libmanager.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class SystemController {

    @Autowired
    private UserServices userServices;

    @RequestMapping("/login")
    public String login(String name, String password, HttpSession session, Model model){
        User user = userServices.doLogin(name,password);
        if(user!=null){
            session.setAttribute(Const.IS_LOGIN, user);

            return "redirect:/book/getBookByPage";
        }
        model.addAttribute("msg","用户名或密码有误");
        return "login";
    }


}
